<template>
  <div>
       <div class="header">
            <router-link to="/home" class="header-title">电商网站首页</router-link>
            <div class="header-menu">
                <router-link to="/cart" class="header-menu-cart">
                    购物车
                </router-link>
            </div>
            <div class="header-menu">
                {{user}}
            </div>
            <div class="header-menu">
                <span @click="logout" class="header-menu-cart">
                    退出登录
                </span>
            </div>
        </div>
  </div>
</template>

<script>
export default {
    name:'myheader',
    data(){
        return {
            user:localStorage.getItem('user'),

        }
    },
    methods:{
        logout(){
            localStorage.removeItem('user')
            this.$router.push('/login')
        }
    }
}
</script>

<style scoped>
    a {
        text-decoration: none;
    }
    .header{
        height: 48px;
        line-height: 48px;
        background: rgba(0,0,0,.8);
        color: #fff;
    }
    .header-title{
        padding: 0 32px;
        float: left;
        color: #fff;
    }
    .header-menu{
        float: right;
        margin-right: 32px;
    }
    .header-menu-cart{
        color: #fff;
    }
    .header-menu-cart span{
        display: inline-block;
        width: 16px;
        height: 16px;
        line-height: 16px;
        text-align: center;
        border-radius: 50%;
        background: #ff5500;
        color: #fff;
        font-size: 12px;
    }
</style>